/*
 *  Copyright (C) 2011  Clint Priest
 *
 *  This file is part of pklib.
 *
 *  pklib is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  pklib is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with pklib.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

var Rect = Class.create( {
	initialize: function(top, left, bottom, right) {
		this._top = top;
		this._left = left;
		this._bottom = bottom;
		this._right = right;
	},
	get top()		{ return Math.min(this._top, 	this._bottom); },
	get left() 		{ return Math.min(this._left,	this._right); },
	get bottom() 	{ return Math.max(this._top, 	this._bottom); },
	get right() 	{ return Math.max(this._left, 	this._right); },
	
	get width() { return this.right - this.left; },
	get height() { return this.bottom - this.top; },
	
	Offset: function(x, y) {
		this._left += x;
		this._right += x;
		this._top += y;
		this._bottom += y;
	},
	Shrink: function(x, y) {
		this._left += x;
		this._right -= x;
		this._top += y;
		this._bottom -= y;
	},
	Expand: function(x, y) {
		this.Shrink(-x, -y);
	}
} );